﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using FreeSrun.Core;
using System.Threading;
using FreeSrun.Forms;



namespace FreeSrun
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            if (args.Length == 1 && (args[0] == "-help" || args[0]=="-h" || args[0]=="-?"))
            {
                MessageBox.Show(Util.HelpInfo);
            }
            else if (args.Length > 0 && !Util.CheckParam(args))
            {
                MessageBox.Show("Incorrect parameters\n" + Util.HelpInfo);
            }
            bool newMutex;
            Mutex m = new System.Threading.Mutex(true, @"Global\" + Application.ProductName, out newMutex);
            {
                if (newMutex)
                {

                    if (args.Length > 0 && Util.CheckParam(args))
                    {
                        Util.Configure(args);
                    }
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    Form frmMain = new FrmMain();
                    Application.Run(frmMain);
                }
                else
                {
                    MessageBox.Show("程序已运行。");
                }
            }

        }



    }
}
